package net.flyinggroup.kafka.domainservice;

import lombok.extern.slf4j.Slf4j;
import net.flyinggroup.kafka.domaincrawler.Domain;
import org.apache.kafka.streams.kstream.KStream;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Consumer;

@Configuration
@Slf4j
public class DomainKafkaConsumer {
    @Bean
    public Consumer<KStream<String, Domain>> domainService() {
        return kstream -> kstream.foreach((key, value) -> {
            log.info("Domain consumed {} status {}", value.getDomain(), value.isDead());
        });
    }
}
